package com.mysoft.gfyx.clue.controller;

import com.mysoft.framework.modeling.dataapi.DataApi;
import com.mysoft.framework.mvc.api.Controller;
import com.mysoft.framework.rpc.annotation.PubAction;
import com.mysoft.framework.rpc.annotation.PubService;
import com.mysoft.framework.rpc.contants.RequestPrefix;
import com.mysoft.gfyx.clue.controller.dto.GetClueFollowRecordsRequestDto;
import com.mysoft.gfyx.clue.controller.dto.GetClueFollowRecordsResponseDto;
import com.mysoft.gfyx.clue.dao.dto.ClueFollowRecordsDto;
import com.mysoft.gfyx.clue.remoteservice.RemoteDeveloperService;
import com.mysoft.gfyx.clue.remoteservice.dto.GetPurchaseContactsRequestDto;
import com.mysoft.gfyx.clue.service.CluecontacterService;
import com.mysoft.gfyx.clue.service.dto.ClueContacterDto;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Map;
import java.util.UUID;

@PubService(value = "/contacterDataApi", prefix = RequestPrefix.API)
@Tag(name = "线索管理-API")
public class ContacterDataApiController extends Controller implements DataApi {

    @Autowired
    private CluecontacterService cluecontacterService;

    @Autowired
    private RemoteDeveloperService remoteDeveloperService;

    @PubAction(value = "/getContracters", method = RequestMethod.POST)
    public List<ClueContacterDto> getContracters(@RequestBody GetClueFollowRecordsRequestDto dto) {
        UUID clueId = UUID.fromString(dto.getClueId());
        GetClueFollowRecordsResponseDto response = new GetClueFollowRecordsResponseDto();
        List<ClueContacterDto> list = cluecontacterService.getClueContactersByClueId(clueId);

        return list;
    }

    @PubAction(value = "/getPurchaseContacts", method = RequestMethod.POST)
    public List<Map<String, Object>> getPurchaseContacts(@RequestBody GetPurchaseContactsRequestDto dto) {
        return remoteDeveloperService.getPurchaseContacts(dto);
    }
}
